(function(){var e=window.BX;if(e&&e["EditForm"]&&e["EditForm"]["Field"]&&e["EditForm"]["Field"]["Enum"])return;e.namespace("BX.EditForm.Field.Enum");e.EditForm.Field.Enum=function(i){this.controlNodeIdJs=i.controlNodeIdJs;this.valueContainerIdJs=i.valueContainerIdJs;this.fieldNameJs=i.fieldNameJs;this.isMultiple=i.isMultiple;this.htmlFieldNameJs=i.htmlFieldNameJs;this.items=JSON.parse(i.items);this.value=JSON.parse(i.value);this.params=JSON.parse(i.params);var t="main-ui-select";if(this.isMultiple){t="main-ui-multi-select"}e(i.controlNodeIdJs).appendChild(e.decl({block:t,name:this.fieldNameJs,items:this.items,value:this.value,params:this.params,valueDelete:this.isMultiple}));this.click=e.delegate(this.click,this);e.bind(e(i.controlNodeIdJs),"click",this.click);e.addCustomEvent(window,"UI::Select::change",e.EditForm.Field.Enum.prototype.changeHandler)};e.EditForm.Field.Enum.prototype={changeHandler:function(i,t){var a=JSON.parse(i.node.getAttribute("data-value"));var l=JSON.parse(i.node.getAttribute("data-params"));if(l.isMulti){var s="";if(e.type.isArray(a)){if(a.length>0){for(var d in a){s+='<input type="hidden" name="'+i.params.fieldName+'[]" value="'+e.util.htmlspecialchars(a[d].VALUE)+'" />'}}else{s+='<input type="hidden" name="'+i.params.fieldName+'[]" value="" />'}e(i.params.fieldName+"_value").innerHTML=s}}else{if(e.type.isPlainObject(a)){e(i.params.fieldName+"_value").value=a["VALUE"]}}},click:function(){this.changeHandler({params:this.params,node:e(this.controlNodeIdJs).firstChild})}}})();
//# sourceMappingURL=enum_ui_type.map.js